import request from "@/utils/request";
import type { LoginData } from "./model";

class AuthAPI {
  /**
   * 登录API
   *
   * @param data {LoginData}
   * @returns
   */
  static login(data: LoginData) {
    const formData = new FormData();
    formData.append("username", data.username!);
    formData.append("password", data.password!);
    formData.append("captchaKey", data.captchaKey || "");
    formData.append("captchaCode", data.captchaCode || "");
    return request<any, SingleResult<string>>({
      url: "/api/login",
      method: "post",
      data: formData,
    });
  }
}

export default AuthAPI;
